import { createApp } from 'vue';
import { createPinia } from 'pinia';

import App from './App.vue';
import router from './router';
import Axios from './api';
import ElementPlus from 'element-plus';

import 'element-plus/dist/index.css';
import './assets/css/body.scss';
import './assets/css/dialog.scss';
import './assets/css/common.scss';
import 'splitpanes/dist/splitpanes.css';
import '@/assets/iconfont/iconfont.css';
import '/src/assets/css/layout.scss';
import * as ElementPlusIconsVue from '@element-plus/icons-vue';
import zhCn from 'element-plus/dist/locale/zh-cn.mjs';


//获取主程序配置文件
// const electronCfg = await window.electron.ipcRenderer.invoke('get-env-config');
//Axios.defaults.baseURL = import.meta.env.VITE_SERVER_URL;

//#region  VxeTable
import VXETable from 'vxe-table';
import 'vxe-table/lib/style.css';
import './themes/vxetabledefault.scss';
import './themes/vxeoverriedstyle.scss';
import './assets/css/isd-body.scss';
import './assets/css/isd-list.scss';
import './assets/css/isd-modal.scss';
import '/src/assets/css/layout.scss';
VXETable.setup({ size: 'mini', zIndex: 99999, table: { size: 'mini' } });
function useTable(app: any) {
  app.use(VXETable);
}
//#endregion

const app = createApp(App);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

app.provide('axios', Axios);
app.config.globalProperties.$http = Axios;
app.config.globalProperties.$routerObj = router;

const size: any = localStorage.getItem('uiSize') || 'small';
app.use(ElementPlus, { size: size, locale: zhCn });

app.use(createPinia());
app.use(router);
app.use(useTable);
app.mount('#app');

app.config.globalProperties.$XModal = VXETable.modal;
